﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Janus.Windows.UI;
using PominaScale.Properties;

namespace PominaScale
{
    public class Configuration
    {
        // Para Port / Scale Port

        #region Port Name
        /// <summary>
        /// PortName = "COM1"
        /// </summary>
        public string PortName
        {
            get { return PominaScale.Properties.Settings.Default.PortName; }
            set
            {
                if (PominaScale.Properties.Settings.Default.PortName != value)
                {
                    PominaScale.Properties.Settings.Default.PortName = value;
                }
            }
        }
        #endregion

        #region Port Name 2
        /// <summary>
        /// PortName = "COM2"
        /// </summary>
        public string PortName2
        {
            get { return PominaScale.Properties.Settings.Default.PortName2; }
            set
            {
                if (PominaScale.Properties.Settings.Default.PortName2 != value)
                {
                    PominaScale.Properties.Settings.Default.PortName2 = value;
                }
            }
        }
        #endregion

        #region Baud Rate
        /// <summary>
        /// BaudRate = 2400
        /// </summary>
        public int BaudRate
        {
            get { return PominaScale.Properties.Settings.Default.BaudRate; }
            set
            {
                if (PominaScale.Properties.Settings.Default.BaudRate != value)
                {
                    PominaScale.Properties.Settings.Default.BaudRate = value;
                }
            }
        }
        #endregion

        #region Baud Rate 2
        /// <summary>
        /// BaudRate = 2400
        /// </summary>
        public int BaudRate2
        {
            get { return PominaScale.Properties.Settings.Default.BaudRate2; }
            set
            {
                if (PominaScale.Properties.Settings.Default.BaudRate2 != value)
                {
                    PominaScale.Properties.Settings.Default.BaudRate2 = value;
                }
            }
        }
        #endregion

        #region Parity
        /// <summary>
        /// Parity = 2
        /// </summary>
        public int Parity
        {
            get { return PominaScale.Properties.Settings.Default.Parity; }
            set
            {
                if (PominaScale.Properties.Settings.Default.Parity != value)
                {
                    PominaScale.Properties.Settings.Default.Parity = value;
                }
            }
        }
        #endregion

        #region Parity 2
        /// <summary>
        /// Parity = 2
        /// </summary>
        public int Parity2
        {
            get { return PominaScale.Properties.Settings.Default.Parity2; }
            set
            {
                if (PominaScale.Properties.Settings.Default.Parity2 != value)
                {
                    PominaScale.Properties.Settings.Default.Parity2 = value;
                }
            }
        }
        #endregion

        #region Data Bits
        /// <summary>
        /// DataBits
        /// </summary>
        public int DataBits
        {
            get { return PominaScale.Properties.Settings.Default.DataBits; }
            set
            {
                if (PominaScale.Properties.Settings.Default.DataBits != value)
                {
                    PominaScale.Properties.Settings.Default.DataBits = value;
                }
            }
        }
        #endregion

        #region Data Bits 2
        /// <summary>
        /// DataBits
        /// </summary>
        public int DataBits2
        {
            get { return PominaScale.Properties.Settings.Default.DataBits2; }
            set
            {
                if (PominaScale.Properties.Settings.Default.DataBits2 != value)
                {
                    PominaScale.Properties.Settings.Default.DataBits2 = value;
                }
            }
        }
        #endregion

        #region Stop Bits
        /// <summary>
        /// StopBits
        /// </summary>
        public int StopBits
        {
            get { return PominaScale.Properties.Settings.Default.StopBits; }
            set
            {
                if (PominaScale.Properties.Settings.Default.StopBits != value)
                {
                    PominaScale.Properties.Settings.Default.StopBits = value;
                }
            }
        }
        #endregion

        #region Stop Bits 2
        /// <summary>
        /// StopBits
        /// </summary>
        public int StopBits2
        {
            get { return PominaScale.Properties.Settings.Default.StopBits2; }
            set
            {
                if (PominaScale.Properties.Settings.Default.StopBits2 != value)
                {
                    PominaScale.Properties.Settings.Default.StopBits2 = value;
                }
            }
        }
        #endregion

        // Company Information

        #region CompanyName
        public string CompanyName
        {
            get { return Settings.Default.CompanyName; }
            set
            {
                if (Settings.Default.CompanyName != value)
                {
                    Settings.Default.CompanyName = value;
                }
            }
        }
        #endregion

        #region CompanyAddress
        public string CompanyAddress
        {
            get { return Settings.Default.CompanyAddress; }
            set
            {
                if (Settings.Default.CompanyAddress != value)
                {
                    Settings.Default.CompanyAddress = value;
                }
            }
        }
        #endregion

        // Path to store the scale data

        #region StorePath
        public string StorePath
        {
            get { return Settings.Default.Stored; }
            set
            {
                if (Settings.Default.Stored != value)
                {
                    Settings.Default.Stored = value;
                }
            }
        }
        #endregion

        #region MM_S2C
        public string MM_S2C
        {
            get { return Settings.Default.MM_S2C; }
            set
            {

                if (Settings.Default.MM_S2C != value)
                {
                    Settings.Default.MM_S2C = value;
                }
            }
        }
        #endregion

        #region MM_C2S
        public string MM_C2S
        {
            get { return Settings.Default.MM_C2S; }
            set
            {

                if (Settings.Default.MM_C2S != value)
                {
                    Settings.Default.MM_C2S = value;
                }
            }
        }
        #endregion

        #region SD_S2C
        public string SD_S2C
        {
            get { return Settings.Default.SD_S2C; }
            set
            {

                if (Settings.Default.SD_S2C != value)
                {
                    Settings.Default.SD_S2C = value;
                }
            }
        }
        #endregion

        #region SD_C2S
        public string SD_C2S
        {
            get { return Settings.Default.SD_C2S; }
            set
            {

                if (Settings.Default.SD_C2S != value)
                {
                    Settings.Default.SD_C2S = value;
                }
            }
        }
        #endregion

        // Printer

        #region ReceiptPrintName
        public string ReceiptPrintName
        {
            get { return Settings.Default.ReceiptPrintName; }
            set
            {
                if (Settings.Default.ReceiptPrintName != value)
                {
                    Settings.Default.ReceiptPrintName = value;
                }
            }
        }
        #endregion

        #region ReportPrintName
        public string ReportPrintName
        {
            get { return Settings.Default.ReportPrintName; }
            set
            {
                if (Settings.Default.ReportPrintName != value)
                {
                    Settings.Default.ReportPrintName = value;
                }
            }
        }
        #endregion

        #region IsPreviewReportPrint
        public bool IsPreviewReportPrint
        {
            get { return Settings.Default.IsPreviewReportPrint; }
            set
            {
                if (Settings.Default.IsPreviewReportPrint != value)
                {
                    Settings.Default.IsPreviewReportPrint = value;
                }
            }
        }
        #endregion

        #region IsPreviewReceiptPrint
        public bool IsPreviewReceiptPrint
        {
            get { return Settings.Default.IsPreviewReceiptPrint; }
            set
            {
                if (Settings.Default.IsPreviewReceiptPrint != value)
                {
                    Settings.Default.IsPreviewReceiptPrint = value;
                }
            }
        }
        #endregion

        #region MarginLeft
        public int MarginLeft
        {
            get { return Settings.Default.MarginLeft; }
            set
            {
                if (Settings.Default.MarginLeft != value)
                {
                    Settings.Default.MarginLeft = value;
                }
            }
        }
        #endregion

        #region MarginTop
        public int MarginTop
        {
            get { return Settings.Default.MarginTop; }
            set
            {
                if (Settings.Default.MarginTop != value)
                {
                    Settings.Default.MarginTop = value;
                }
            }
        }
        #endregion

        #region MarginRight
        public int MarginRight
        {
            get { return Settings.Default.MarginRight; }
            set
            {
                if (Settings.Default.MarginRight != value)
                {
                    Settings.Default.MarginRight = value;
                }
            }
        }
        #endregion

        #region MarginBottom
        public int MarginBottom
        {
            get { return Settings.Default.MarginBottom; }
            set
            {
                if (Settings.Default.MarginBottom != value)
                {
                    Settings.Default.MarginBottom = value;
                }
            }
        }
        #endregion

        // Commit

        public void Commit()
        {
            Settings.Default.Save();
        }

    }
}
